package de.pierrepoenisch.checkyoursite.client;

import com.google.gwt.user.client.rpc.IsSerializable;

/**
 * This class is the basis class for all enumeration classes. It makes sure that the enum classes
 * are serializable. Due to the different serialization concept of GWT we can not make this class 
 * easily serializable by
 * implementing readResolve(). It is possible to have more than one instance of a state. To compare
 * these instances we have implemented the method equals(CheckResultStateET state2).
 * 
 * @author ppoenisc
 *
 */
public class AbstractEnum implements IsSerializable {

	//name is used to identify instance in deserialization
	protected String name;
	
	protected AbstractEnum(String name){
		this.name = name;
	}

	//this constructor is neede by the GWT to be serializable
	public AbstractEnum() {
	}
	
	//used to compare different instances of the same enum element by the name
	public boolean equals(AbstractEnum et2){
		if (this.name.equals(et2.getName())){
			return true;
		}else{
			return false;
		}
	}
	
	//used to compare states
	public String getName(){
		return name;
	}
}
